﻿SmitearWebGL.Core.Geometry.Edge = Class.extend(
{
	/******** constructor ********/
	
	init : function( i0, i1, p0, p1 )
	{
		/******** public property ********/
		
		this.i0 = i0;
		this.i1 = i1;
		this.p0 = p0;
		this.p1 = p1;
		
		this.faceInstance = null;
		this.faceSlot = -1;
		
		this._registClass( "SmitearWebGL.Core.Geometry.Edge" );
	}
	,
	setVertex : function( vertex, index, indicesIndex )
	{
		switch ( index )
		{
			case 0:
				this.p0 = vertex;
				this.i0 = indicesIndex;
				break;
			case 1:
				this.p1 = vertex;
				this.i1 = indicesIndex;
				break;
		}
		vertex.correlativeFaces.push( this.faceInstance );
	}
	,
	compare : function( to, reverse )
	{
		reverse = reverse == undefined ? false : true;
		
		var p0 = this.p0;
		var p1 = this.p1;
		var tp0 = to.p0;
		var tp1 = to.p1;
		
		if ( reverse )
		{
			tp0 = to.p1;
			tp1 = to.p0;
		}
		
		if ( p0.x == tp0.x && p0.y == tp0.y && p0.z == tp0.z && 
			p1.x == tp1.x && p1.y == tp1.y && p1.z == tp1.z )
		{
			return true;
		}
		
		return false;
	}
	,
	clone : function()
	{
		return new SmitearWebGL.Core.Geometry.Edge( this.p0, this.p1 );
	}
}
);